<aside class="main-sidebar">

    <section class="sidebar">

        <!-- Sidebar user panel -->
        <div class="user-panel">
            <div class="pull-left image">
                <img src="<?= $directoryAsset ?>/img/user2-160x160.jpg" class="img-circle" alt="User Image"/>
            </div>
            <div class="pull-left info">
                <p><?=\Yii::$app->user->identity->profile->name ?></p>

                <a href="#"><i class="fa fa-circle text-success"></i> Online</a>
            </div>
        </div>

        <!-- search form -->
        <form action="#" method="get" class="sidebar-form">
            <div class="input-group">
                <input type="text" name="q" class="form-control" placeholder="Search..."/>
              <span class="input-group-btn">
                <button type='submit' name='search' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i>
                </button>
              </span>
            </div>
        </form>
        <!-- /.search form -->
        <?php
            $callback = function ($menu)
            {
                $base = ['label' => $menu['name'], 'url' => [$menu['route']], 'items' => $menu['children']];
                if (trim($menu['data']) != '')
                {
                    $base += json_decode($menu['data'], TRUE);
                }
                if (! isset($base['icon'])) {
                    $base['icon'] = 'fa  fa-circle-thin';
                }
                return $base;
            };
            $items = \mdm\admin\components\MenuHelper::getAssignedMenu(Yii::$app->user->id, 1, $callback);
            if (YII_ENV == 'dev')
            {
                $items[] = [
                        'label' => 'Same tools',
                        'template' => '<a href="{url}"><i class="fa fa-share"></i>  <span>{label}</span> <i class="fa fa-angle-left pull-right"></i></a>',
                        'url' => '',
                        'items' => [
                            ['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii'],],
                            ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug'],]
                        ],
                    ];
            }
            
            $config = [
                'options' => ['class' => 'sidebar-menu tree', 'data-widget'=> 'tree'],
//                'encodeLabels'    => false,
//                'activateParents' => true,
               // 'linkTemplate'    => '<a href="{url}"><i class="fa fa-circle-o"></i>  <span>{label}</span></a>',
               // 'submenuTemplate' => '<ul class="treeview-menu">{items}</ul>',
                'items'           => $items
            ];
            echo dmstr\widgets\Menu::widget($config);
        ?>
    </section>

</aside>
